package com.third;

import com.firstfactory.Person;
import com.second.MakePersonTwo;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;

public class MakePersonThree {
    public Person makePerson() {
        //读取配置文件Properties加载properties配置文件
        Properties properties=new Properties();
        //获取流对象
        InputStream is= MakePersonThree.class.getClassLoader().getResourceAsStream("person.properties");

        try {
            properties.load(is);
            //获取全限定类名
            String value = properties.getProperty("person");
            //根据全限定类名获取对象
            Class<?> clazz = Class.forName(value);
            Object o = clazz.newInstance();
            return (Person)o;
        } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
